package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 报修申请
 * </p>
 *
 * @author dqq
 * @date 2022-11-24
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "RepairReportRepairTypeEnum", description = "报修类型 #{HOME_REPAIR:主场报修;ONLINE_REPAIR:线上报修；ON_SITE_REPAIR:现场报修-枚举")
public enum RepairReportRepairTypeEnum implements BaseEnum {

    /**
     * HOME_REPAIR="主场报修"
     */
    HOME_REPAIR("主场报修"),
    /**
     * ONLINE_REPAIR="线上报修；ON_SITE_REPAIR:现场报修"
     */
    ONLINE_REPAIR("线上报修；ON_SITE_REPAIR:现场报修"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static RepairReportRepairTypeEnum match(String val, RepairReportRepairTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static RepairReportRepairTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(RepairReportRepairTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "HOME_REPAIR,ONLINE_REPAIR", example = "HOME_REPAIR")
    public String getCode() {
        return this.name();
    }

}
